package cn.kgc.service.impl;

import cn.kgc.dao.RoleDao;
import cn.kgc.pojo.Role;
import cn.kgc.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

/**
 * 业务层接口的实现类
 */
@Service("roleServiced")
public class RoleServiceImpl implements RoleService {
      @Autowired
      private RoleDao roleDao;

    /**
     * 查询所有角色
     *
     * @return
     */
    public List<Role> findAllRole() throws SQLException {
        return roleDao.getAllRole();
    }

    /**
     * 根据id查询角色
     *
     * @param id
     * @return
     */
    public Role findRoleById(Integer id) throws SQLException {
        return roleDao.getRoleById(id);
    }

    /**
     * 添加角色
     *
     * @param role
     * @return
     */
    public Integer saveRole(Role role) throws SQLException {
        return roleDao.addRole(role);
    }

    /**
     * 修改角色
     *
     * @param role
     * @return
     */
    public Integer modifyRole(Role role) throws SQLException {
        return roleDao.updateRole(role);
    }

    /**
     * 删除角色
     *
     * @param id
     * @return
     */
    public Integer removeRole(Integer id) throws SQLException {
        return roleDao.delRole(id);
    }
}
